package core.genetic.mutation;

import utility.*;
import core.*;
import core.genetic.*;

public class AllGenesMutation implements HromozomMutation {

	

	public final double mutRatePop;
	public final double mutRateInd;
	
	public AllGenesMutation(double mutRagePop, double mutRateInd) {
		this.mutRatePop = mutRagePop;
		this.mutRateInd = mutRateInd;
	}
	
	
	@Override
	public void mutate(Individual ind) {
		if (Utils.random.nextDouble() > mutRatePop)
			return;

		int len = ind.getLength();
		for (int i = 0; i < len; i++)
		{
			if (Utils.random.nextDouble() < mutRateInd)
			{ 
				ind.setGene(i,Mode.mode.singleMutation.getMutated(ind.getGene(i)));
			}
		}
	}
	
}
